package com.mall.service;

import java.util.List;

import com.mall.ibatis.bean.EFunction;
import com.mall.ibatis.bean.Function;
import com.mall.ibatis.bean.ICell;
import com.mall.ibatis.bean.JQGrid;
import com.mall.ibatis.bean.FunctionMenu;
import com.mall.ibatis.persistence.iface.FunctionMenuDAO;
import com.mall.ibatis.persistence.DaoConfig;

import com.ibatis.dao.client.DaoManager;

public class FunctionMenuService
{
	private static final FunctionMenuService instance = new FunctionMenuService();
	
	private DaoManager daoManager = DaoConfig.getDaomanager();
	
	private FunctionMenuDAO functionMenuDAO = null;
	
	private FunctionMenuService()
	{
		functionMenuDAO  = (FunctionMenuDAO) daoManager.getDao(FunctionMenuDAO.class);
	}
	
	public static FunctionMenuService getInstance()
	{
		return instance;
	}
	
	
	public List<FunctionMenu> selectAllFunctionMenu() throws Exception
	{
		return functionMenuDAO.selectAllFunctionMenu();
	}
	
	
	public FunctionMenu selectFunctionMenu(FunctionMenu functionMenu)  throws Exception
	{
		return functionMenuDAO.selectFunctionMenu(functionMenu);
	}
	
	
	public String insertFunctionMenu(FunctionMenu functionMenu) throws Exception
	{
		return functionMenuDAO.insertFunctionMenu( functionMenu);
	}
	
	public void updateFunctionMenu(FunctionMenu functionMenu) throws Exception
	{
		functionMenuDAO.updateFunctionMenu( functionMenu);
	}
	
	public void deleteFunctionMenu(FunctionMenu functionMenu) throws Exception
	{
		functionMenuDAO.deleteFunctionMenu(functionMenu);
	}
	
	public EFunction selectEFunction(EFunction eFunction) throws Exception
	{
		return functionMenuDAO.selectEFunction(eFunction);
	}
	
	public EFunction selectEFunctionForUpdate(EFunction eFunction) throws Exception
	{
		return functionMenuDAO.selectEFunctionForUpdate(eFunction);
	}
	
	public int insertEFunction(EFunction eFunction,String demand,String detial,String test) throws Exception
	{
		return functionMenuDAO.insertEFunction(eFunction,demand,detial,test);
	}
	
	public EFunction downLoadDOC(EFunction eFunction,String downFile) throws Exception
	{
		return functionMenuDAO.downLoadDOC(eFunction,downFile);
	}
	
	public int deleteEFunction(EFunction eFunction) throws Exception
	{
		return functionMenuDAO.deleteEFunction(eFunction);
	}
	
	public Function selectFunctionName(Function function) throws Exception
	{
		return functionMenuDAO.selectFunctionName(function);
	}
	
	public int updateEFunction(EFunction eFunction,String demand,String detial,String test) throws Exception
	{
		return functionMenuDAO.updateEFunction(eFunction,demand,detial,test);
	}
	
	public JQGrid getFunctionMenuList(List<FunctionMenu> functionMenuList,int page,int total) throws Exception
	{
		JQGrid jqGrid = new JQGrid();
		
		jqGrid.setPage(page);
		jqGrid.setRecord(functionMenuList.size());
		jqGrid.setTotal(total);
		
		List<ICell> rowsList = jqGrid.getRowXML();
		
		
		for( FunctionMenu functionMenu :functionMenuList)
		{
			rowsList.add(functionMenu);
		}
		
		
		return jqGrid;
	}
	
	
	
}